package com.haoze.nurseapp.controller;

import com.haoze.common.response.Result;
import com.haoze.common.response.ResultGenerator;
import com.haoze.nurseapp.dto.SpecimenTransferDTO;
import com.haoze.nurseapp.dto.task.TaskExecuteBatchDTO;
import com.haoze.nurseapp.service.SpecimenService;
import com.haoze.nurseapp.service.feign.PatientOrderService;
import com.haoze.nurseapp.vo.EmrFile;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * 标本转运
 * @author lufq
 * @date 2020/8/1
 */
@RestController
@Api(value = "检验标本转运")
@RequestMapping("/nurseapp/labSpecimenTransfer")
public class LabSpecimenTransferController {
    @Autowired
    SpecimenService specimenService;
    @Resource
    PatientOrderService patientOrderService;

    /**
     * 标本待转运列表
     * @param pageNum
     * @param pageSize
     * @param wardId
     * @return
     */
    @GetMapping("/queryLabWaitTransfer")
    @ApiOperation(value = "标本待转运列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页数", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页长", required = true),
            @ApiImplicitParam(name = "wardId", value = "病区", required = true)
    })
    public Result queryLabWaitTransfer(@RequestParam int pageNum, @RequestParam int pageSize,@RequestParam String wardId) {
        return specimenService.queryLabWaitTransfer(pageNum,pageSize,wardId);
    }

    /**
     * 扫描标本条码
     * @param sepcimenNum
     * @return
     */
    @GetMapping("/scan/specimen")
    @ApiOperation(value = "扫描标本条码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sepcimenNum", value = "标本条码", required = true)
    })
    public Result querySpecimen(@RequestParam(required = true) String sepcimenNum) {
        return specimenService.scannSpecimen(sepcimenNum);
    }

    /**
     * 确认转运
     * @param specimenTransferDTO
     * @return
     */
    @PostMapping("/confirmTransfer")
    @ApiOperation(value = "确认转运")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "specimenTransferDTO", value = "标本转运对象", required = true)
    })
    public Result confirmTransfer(@RequestBody SpecimenTransferDTO specimenTransferDTO){
        return specimenService.confirmTransfer(specimenTransferDTO);
    }


    /**
     * 标本运转历史列表
     * @param startDate
     * @param endDate
     * @param keywords
     * @param pageNum
     * @param pageSize
     * @param wardId
     * @return
     */
    @GetMapping("/queryLabHistoryTransfer")
    @ApiOperation(value = "标本运转历史列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false),
            @ApiImplicitParam(name = "keywords", value = "关键字查询", required = false),
            @ApiImplicitParam(name = "pageNum", value = "页数", required = true),
            @ApiImplicitParam(name = "pageSize", value = "页长", required = true),
            @ApiImplicitParam(name = "wardId", value = "病区", required = true)
    })
    public Result queryLabHistoryTransfer(@RequestParam(required = false) String startDate,@RequestParam(required = false) String endDate,
                                          @RequestParam(required = false) String keywords,
                                          @RequestParam int pageNum, @RequestParam int pageSize,@RequestParam String wardId) {
        return specimenService.queryLabHistoryTransfer(startDate,endDate,keywords,pageNum,pageSize,wardId);
    }


    /**
     * 查看报告接口
     * @param specimenNum
     * @param reqNum
     * @param serialNumber
     * @return
     */
    @GetMapping("/viewReport")
    @ApiOperation(value = "查看报告接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "specimenNum", value = "标本条形码编号", required = true),
            @ApiImplicitParam(name = "reqNum", value = "电子申请单编号", required = true),
            @ApiImplicitParam(name = "serialNumber", value = "申请单序号", required = true)
    })
    public Result viewReport(@RequestParam String specimenNum, @RequestParam String reqNum,@RequestParam String serialNumber) {
        return specimenService.viewReport(specimenNum,reqNum,serialNumber);
    }

    /**
     * 根据taskBatchId查询转运详情信息
     * @param taskBatchId
     * @param statusFlag
     * @return
     */
    @GetMapping("/querySpecimenTransferDetail")
    @ApiOperation(value = "根据taskBatchId查询转运详情信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "taskBatchId", value = "任务频次Id", required = true),
            @ApiImplicitParam(name = "statusFlag", value = "根据标记来查询是未转运还是历史转运信息", required = true)
    })
    public Result querySpecimenTransferDetail(@RequestParam String taskBatchId,@RequestParam String statusFlag) {
        return specimenService.querySpecimenTransferDetail(taskBatchId,statusFlag);
    }


    @GetMapping("/queryNurseWorkerList")
    @ApiOperation(value = "根据病区获取护工信息")
    public Result queryNurseWorkerList(@RequestParam int pageNum, @RequestParam int pageSize,@RequestParam(required=false) String keyWords) {
        return specimenService.queryNurseWorkerList(pageNum,pageSize,keyWords);
    }



    /*@GetMapping("/test")
    public Result viewReport1() {
        //patientOrderService.createNextTaskNode(map.get("taskExecuteDetailId"),Integer.valueOf(map.get("BATCH_NO")), userId, "", "", "");
        patientOrderService.createNextTaskNode("9927c359189146c6b47f1f2fac7c1626",1, "9029AA7D2AF83AFAE053ED5B14AC30BB", "", "", "");
        return ResultGenerator.genOkResult();
    }*/

}
